{extend name="public/base"}

{block name="title"}就行天下-补货申请{/block}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/home/css/index.css" />
{/block}

{block name="main"}
<div class="pageControl productList bg-f7">
    <div class="main-top"></div>
    <div class="msui_nav msui_navTop noBorder">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">需补货</h1>
        <a href="" class="msui_navTop-right msui_navTop-cnav"><i class="micon-cnav"></i></a>
    </div>
    <div class="mtab_list mtop05">
        <div class="weui-cell img_35_1">
            <div class="weui-cell__hd mr03">
                <img src="{$data.thumb}" alt="">
            </div>
            <div class="weui-cell__bd">
                <p>{$data.name}</p>
                <p>品牌：<span>{$data.brand_name}</span></p>
            </div>
        </div>
    </div>
    <form action="?" method="post">
        <div class="weui-cell">
            <div class="weui-label">
                <span>数量</span>
            </div>
            <div class="weui-cell__bd">
                <input type="number" name="num" class="weui-input" placeholder="请输入您需要的数量" value="50">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                <span>备注</span>
            </div>
            <div class="weui-cell__bd">
                <input type="text" class="weui-input" name="msg" placeholder="请输入您补货的备注">
            </div>
        </div>
        <div class="weui-cells__tips">注：每次申请数量不能大于50</div>
        <input type="hidden" name="product_id" value="{$id}" />
        <input type="hidden" name="shop_id" value="{$shop_id}" />
        <div class="p05">
            <a href="javascript:;" class="cl-f weui-btn bg-c40 border-radius-10 send_form">提交</a>
        </div>
    </form>

</div>
{/block}

{block name="javascript"}
<script>
    SCOPE.upload_img_type = 3;
    $(function () {
        $(".send_form").click(function () {

            var _form = $('form');
            if ($('input[name="num"]').val() > 50) {
                $.toptip('补货数量不能大于50');
                return false;
            }
            $.showLoading('正在提交。。');
            $.ajax({
                type : _form.attr('method'),
                url : _form.attr('action'),
                data : _form.serialize(),
                dataType : 'json',
                success : function (msg) {
                    if (msg.code == 200) {
                        window.location.href = "{:url('replenishment_list', ['id' => $shop_id])}";
                    } else{
                        $.hideLoading();
                        $.toptip(msg.msg);
                    }
                }
            });
        });
    });
</script>
{/block}